<extend name="Public/base" />

<block name="body">
<style>
 .add_record div ul li{
    list-style: none;
    margin-top: 30px;
    margin-bottom: 30px;
    margin-left: -50px;
 }
 .add_record div ul li span{
    line-height: 30px;
    /*width: 60px;*/
    /*text-align: right;  */
 }
 .add_record div ul li input{
    width: 250px;height: 30px;
    float: right;
    margin-left: 10px;
    border: solid 1px #ccc;
    border-radius: 3px; 
    padding-left: 5px;
    line-height: 26px;
 }
 .add_record div ul li select{
    width: 250px;height: 30px;
    float: right;
 }
 .add_record div ul li input:focus { 
    border-color: #66afe9;
    outline: 0;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, 0.6);
}
.c_green {
    background-color: #5cb85c !important;
    border-color: #5cb85c !important;
    color: white !important;
}
.c_green:hover {
	background-color: #1da51d !important;
    border-color: #1da51d !important;
}
.table tbody td {
    vertical-align: middle !important;
}
._input {
	
}
._input input {
	
}
.search_name {
	border: solid 1px #ccc;
	padding: 4px 4px 4px 8px; 
	margin-right: 5px; 
	border-radius: 4px;
}
.btn-primary { 
    color: #fff;
    background-color: #337ab7;
    border-color: #2e6da4; 
}
.btn-primary:hover {
	color: #fff; 
	background-color: #286090; 
	border-color: #204d74;
}
.btn-info { 
    color: #fff;
    background-color: #5bc0de;
    border-color: #46b8da; 
}
.btn-info:hover {
	color: #fff; 
	background-color: #39b3d7; 
	border-color: #269abc;
}
.btn-warning { 
    color: #fff;
    background-color: #f0ad4e;
    border-color: #eea236; 
}
.btn-warning:hover {
	color: #fff; 
	background-color: #ec971f; 
	border-color: #d58512;
}
.btn-danger { 
    color: #fff;
    background-color: #d9534f;
    border-color: #d43f3a; 
}
.btn-danger:hover {
	color: #fff; 
	background-color: #c9302c; 
	border-color: #ac2925;
}
 </style>
<!-- 标题栏 -->
<div class="main-title">
    <h2>采购单</h2>
</div>
<!-- 产品 -->
<div class="data" style="display: none; ">
    <select   name="product_no">
        <volist name="li" id="vo">
            <option value='{$vo.number}'>{$vo.name}</option>
        </volist>
    </select>
</div>
<!-- 原材料 -->
<div class="material_id" style="display: none; ">
    <select   name="material_id">
        <volist name="lists" id="vo">
            <option value='{$vo.id}'>{$vo.name}</option>
        </volist>
    </select>
</div>
<!-- 供应商 -->
<div class="dataname"  style="display: none;" >
    <select  name="buId">
        <volist name="info" id="vo">
             <option value='{$vo.id}'>{$vo.name}</option>
        </volist> 
    </select>
</div>
<div class="panel panel-default">
    <div class="panel-heading">     
        <div class="fl">
            <button id="add_finance" class="btn btn-default c_green">新 增</button> 
            <button id="jq2excel" class="btn btn-info">导 出</button> 
            <div class="_input" style="float: right;">
                 <form action="{:U('index')}" method="post">
                    <input type="text" name="username" class="search_name" placeholder="搜索用户名"> 
                   	<input  type="submit"  class="btn btn-warning search" value="查询">
                   	<input  type="submit"  class="btn btn-primary search" value="返回"> 
                </form>
            </div>

        </div>      
    </div><!-- /.panel-heading --> 
    
    <div class="panel-body topa" > 
        <div class="table-responsive">      
            <table class="table table-striped table-bordered table-hover excel" id="dataTables-user"><!-- 必须设定表格的id == -->
                <thead>
                    <tr>       
                        <th class="">编号</th>
                        <th>采购编号</th>
                        <th>原材料</th>
                        <th class="">是否有磁</th> 
                        <th class="">产品名称</th>
                        <th class="">厚度(cm)</th>
                        <th class="">宽度(cm)</th>
                        <th class="">重量(kg)</th> 
                        <th class="">每吨价格(元)</th> 
                        <th class="">供用商</th> 
                        <th class="">入库时间</th>
                        <th>状态</th>
                        <th class="">操作</th>
                    </tr>
                </thead>
                <tbody>
                    <foreach name="list" item="vo">
                      <if condition = '$vo.isDelete eq 0'>	
                        <tr> 
                            <td>{$vo.id}</td>
                            <td>{$vo.productNo}</td>
                            <td>{$vo.material_name}</td>
                            <if condition = "$vo.is_magnetic eq 1">
                            	<td>否</td>
                                 <else/>
                               	<td>是</td>
                            </if>
                            <td>{$vo.name}</td> 
                            <td>{$vo.thickness}</td>  
                            <td>{$vo.width}</td>
                            <td>{$vo.weight}</td> 
                            <td>{$vo.price}</td>  
                            <td>{$vo.subpplier_name}</td>                         
                            <td style="color: red;">{$vo.billDate|date="Y-m-d",###}</td>
                            <td>{$vo.status|show_status_product}</td>
                            <td class="txt_c noExl">
                            	   <if condition = "$vo.status eq 1">
                            		 <button class="btn btn-success ajax-get confirm" url="{:U('Production/production_add',array('id'=>$vo['id']))}" target-form="ids">投入生产</button>
                            	   </if>
                            		 <button class="btn btn-danger del" value="{$vo.id}">删除</button>
                            </td>
                        </tr>
                     </if>
                    </foreach>
                </tbody>
            </table>  
            <div class="page">{$page}</div>
        </div><!-- /.table-responsive --> 

        <style>
            .topa{
                position: relative;
            }   
            .newly{
                width: 600px;
                height: 500px;
                position: absolute;
                top: 20%;
                left: 50%;
                margin-left: -300px;  
            }
            .add_record { text-align: center; }
            .add_record > div { display: inline-block; margin-top: 38px; }
            .add_record ul { margin: 0; }
            .add_record ul li {  }
            .add_record ul li span { float: left; }
            .add_record ul li input { float: left; }
        </style>        
        <!-- 用户新增隐藏 -->  
    </div><!-- /.panel-body -->
    <!-- 分页 -->
    <div class="page">
        {$_page}
    </div>
</div><!-- /.panel -->   
</block> 
<block name="script">
<link rel="stylesheet" href="__STATIC__/datetimepicker/css/datetimepicker.css" /> 
<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
<script src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>   
<script type="text/javascript" src="__JS__/jquery.table2excel.min.js"></script> 
 
<script type="text/javascript">
$(function(){
    //新增按钮
    $("#action_add").click(function(){
        window.location.href = $(this).attr('url');
    });  
    //导出数据
  	var date2time="<?php echo date('Y-m-d');?>";
  	$('#jq2excel').click(function(){
      var myDate = new Date();
      $('.excel').table2excel({
          exclude:".noExl",
          name: "计数录入"+date2time,
          filename: "计数录入"+ date2time,
          exclude_img: true,
          exclude_links: true,
          exclude_inputs: true
      });
  	})
})
</script> 

<script type="text/javascript">
	
$('#goback').on('click',function () {
    $('#addshow').hide();
})
//新增财务记录
var _htm =  
    "<form id='_form' name='myform' method='post' role='form'>"+
	    "<div class='add_record'>"+
	        "<div>"+
	            "<ul>"+     
	                "<li class='c_f material_id'>"+
	                    "<span>原材料</span>"+
	                    // "<input type='text' name = 'product_type'>"+
	                "</li>"+
	                "<li class='c_f'>"+
	                    "<span>厚度(cm)</span>"+
	                    "<input type='text' name = 'thickness'>"+  
	                "</li>"+ 
	                "<li class='c_f'>"+
	                    "<span>规格(宽度)(cm)</span>"+
	                    "<input type='text' name='width'>"+
	                "</li>"+
	                "<li class='c_f'>"+
	                    "<span>重量(kg)</span>"+
	                     "<input type='text' name='weight'>"+
	                "</li>"+
	                "<li class='c_f'>"+
	                    "<span>每吨价格(元)</span>"+
	                     "<input type='text' name='price'>"+
	                "</li>"+
                    "<li class='c_f product_name'>"+
                        "<span>产品</span>"+
                        // "<input type='text' name='li[name]'>"+
                    "</li>"+ 
	                 "<li class='c_f supplier_name'>"+
                        "<span>供应商</span>"+
                        // "<input type='text' name='li[name]'>"+
                    "</li>"+           
	                "<p>"+
	                    "<button class='btn btn-default c_green' id='submit' >确 定</button>"+ 
	                "</p>"+ 
	            "</ul>"+
	        "</div>"+
	    "</div>"+
    "</form>";
$('#add_finance').click(function(){
    //新增记录层
    layer.open({ 
      title: '新增计数录入', 
      title: '入库添加', 
      type: 1,
      skin: 'layui-layer-rim', //加上边框
      area: ['500px', '700px'], //宽高
      content: _htm
    });
    $('.supplier_name span').after( $('.dataname').html());
    $('.product_name span').after( $('.data').html());
    $('.material_id span').after( $('.material_id').html());
});
var boole = true;
$(document).on('click','#submit',function(){
    $('.add_record ul li').each(function(){
        var input = $(this).find('input').val();  
        if(input == ''){
            boole = false;
            layer.msg('请填写完整内容!'); 
            return false;
        }else{
            boole = true;
        }
    });   
    if(boole){   	  
    	  var info = $('#_form').serialize();   	  
          $.ajax({
          	type:"post",
          	url:"__URL__/add",
          	data:info,
          	async:true,
          	success:function(data){
                // window.location.reload();
          	}
          });
    } 
  
    return false;
});
//删除
 $(".txt_c").on("click",".del",function(){
 	var del = confirm("你确定要删除吗？");
 	if(del){
 		$(this).parent().parent().remove();
 		var id = $(this).val();
 		$.post("__URL__/delpurchase",{"id":id},function(data){
 			console.log(data);
 		})
 	}
 })

</script>
 
</block>
